package com.cloudcc.mobile.parser;

import org.json.JSONObject;

import com.cloudcc.mobile.entity.addmicropost.AddMicroPostMessage;
import com.cloudcc.mobile.entity.addmicropost.AddMircReturnData;
import com.cloudcc.mobile.util.Json;
import com.cloudcc.mobile.util.Tools;

public class AddMicroPostMessageParser {
	/** * 解析发布chatter返回的数据 * @param json * @return */
	public static AddMicroPostMessage addMicroPost(String json) {
		AddMicroPostMessage msg = new AddMicroPostMessage();
		try {
			JSONObject obj = new JSONObject(json);
			msg.setResult(obj.getBoolean("result"));
			msg.setReturnCode(obj.getString("returnCode"));
			msg.setReturnInfo(obj.getString("returnInfo"));
			JSONObject addmicro = obj.getJSONObject("data");
			AddMircReturnData post = (AddMircReturnData) Json.toObject(
					addmicro.toString(), AddMircReturnData.class);
			msg.setId(post.getId());
		} catch (Exception e) {
			Tools.handle(e);
		}
		return msg;
	}
}
